package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCDemo10 {
    public static void main(String[] args) {
        try  (Connection conn = DBUtil.getConnection();){
            String  sql = "UPDATE userinfo " +"SET password=?,nickname=?,age=? " +"WHERE id=?";
            PreparedStatement statement = conn.prepareStatement(sql);
            statement.setString(1,"123456");
            statement.setString(2,"张三");
            statement.setInt(3,18);
            statement.setInt(4,1);
            int num = statement.executeUpdate();
            System.out.println(num>0?"修改成功":"修改失败");
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
